import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import './style/appleItem.scss';
@inject('store')
@observer
class AppleItem extends Component {
  render() {
    let { apple, eatApple } = this.props;
    console.log('xxthis.props',  this.props)
    return (
      <div className="appleItem">
        <div className="apple"><img src='https://github.com/cuiweijun/redux-mobx-immutable-cart/blob/master/src/images/apple.png' alt=""/></div>
        <div className="info">
          <div className="name">红苹果 - { apple.id }号</div>
          <div className="weight">{ apple.weight }克</div>
        </div>
        <div className="btn-div">
          <button onClick={()=>eatApple(apple.id)}> 吃掉 </button>
        </div>
      </div>
    )
  }
}

// AppleItem.propTypes = {
//   apple: React.PropTypes.object.isRequired     // 单个苹果的数据
// };

export default AppleItem
